package com.itheima.HomeWork.homework01;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class InputStreamTest {
    public static void main(String[] args) throws IOException {
        read1();
        System.out.println("======");
        read2();
    }

    public static void read1() throws IOException {
        //TODO 一次读取一个字节
        FileInputStream fis = new FileInputStream("E:\\ttt\\fil01.txt");
        int a;
        while ((a = fis.read()) != -1) {
            System.out.println((char) a);
        }
        fis.close();
    }

    public static void read2() throws IOException {
        //TODO 一次读取多个字节
        FileInputStream fis2 = new FileInputStream("E:\\ttt\\fil01.txt");
        int b;
        byte[] bay = new byte[3];
        while ((b = fis2.read(bay)) != -1) {
            System.out.println(new String(bay, 0, b));
        }
        fis2.close();
    }
}